package com.tianpengtech.admin.task;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class SysConfigDao {

	public static SysConfigDao ME = new SysConfigDao();
	public static int TASK_COUNT_MODE_DEV = 1;
	public static int TASK_COUNT_MODE_PRO = 0;
	public static int SEND_TASK_SMS_YES = 1;
	public static int SEND_TASK_SMS_NO = 0;
	public static int TASK_FAIR_OPEN = 1;
	public static int TASK_FAIR_CLOSE = 0;
	
	
	public boolean getTaskCountMode(){
		Record record =readConfig("TASK_COUNT_MODE");
		return record.getInt("task_count_mode")==TASK_COUNT_MODE_DEV;
	}
	
	public boolean isSendTaskSMS(){
		Record record =readConfig("TASK_COUNT_MODE");
		return record.getInt("is_send_task_sms")==SEND_TASK_SMS_YES;
	}
	
	public Record readConfig(String type){
		String sql = "select * from fair_sys_setting where type=?";
		Record record = Db.findFirst(sql,type);
		return record;
	}
	
	
	public boolean isOpenFairLevel(){
		Record record =readConfig("TASK_COUNT_MODE");
		return record.getInt("is_task_fair")==TASK_FAIR_OPEN;
	}
}
